<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>華信商会(株) 販売管理業務システム</title>
    <LINK href="/css/financials.css" rel="stylesheet" type="text/css">
    <META http-equiv="Content-Type" content="text/HTML; charset=UTF-8">
    <script language="JavaScript" src="/js/Common.js"></script>
    <style type="text/css">
        <!--
        BODY {
            background-color: #F8F9FB;
            margin-left: 0px;
            margin-top: 0px;
            margin-right: 0px;
            margin-bottom: 0px;
        }
        .style13 {
            color: #FFFFFF;
            font-weight: bold;
        }
        .style28 {
            font-family: "ＭＳ ゴシック";
            font-size: 12px;
        }
        .error-message {  /* 错误提示样式 */
            color: red;
            font-weight: bold;
            margin: 10px 0;
        }
        .success-message {  /* 成功提示样式 */
            color: green;
            font-weight: bold;
            margin: 10px 0;
        }
        /* 非活性メニュー共通スタイル */
        .disabled {
            pointer-events: none;
            opacity: 0.5;
            cursor: not-allowed;
        }

        .disabled a {
            pointer-events: none;
        }
        -->
    </style>
</head>
<body onLoad="goforit(),on_focus()">
<script type="text/javascript" th:src="@{/js/menu.js}"></script>
<script type="text/javascript">
    // 处理检索逻辑：查询商品后启用更新按钮
    function handleSearch() {
        // 获取库存数输入框的值（检索后回显）
        const zayikosuuInput = document.querySelector('input[name="zayikosuu"]');
        const zayikosuu = zayikosuuInput.value.trim();
        // 获取更新按钮和入库数量输入框
        const updateBtn = document.getElementsByName("submit")[1];
        const nyuukosuuInput = document.querySelector('input[name="nyuukosuu"]');
        const shouhinCodeInput = document.querySelector('input[name="shouhin_code"]');

        // 检索到有效库存（非空且为数字）
        if (zayikosuu && !isNaN(zayikosuu) && parseInt(zayikosuu) >= 0) {
            updateBtn.disabled = false; // 启用更新按钮
            nyuukosuuInput.disabled = false; // 启用入库数量输入
            document.getElementsByName("submit")[0].disabled = true; // 禁用检索按钮
            shouhinCodeInput.readOnly = true; // 商品代码设为只读（而非禁用，确保值能提交）
            nyuukosuuInput.focus(); // 聚焦到入库数量
        } else {
            // 未检索到有效商品，保持禁用
            updateBtn.disabled = true;
            nyuukosuuInput.disabled = true;
            alert("商品が見つかりません。正しい商品コードを入力してください。");
        }
    }

    // 处理更新逻辑：校验入库数量并提交
    function handleUpdate() {
        const nyuukosuuInput = document.querySelector('input[name="nyuukosuu"]');
        const nyuukosuu = nyuukosuuInput.value.trim();

        // 校验入库数量是否为正数
        if (!nyuukosuu) {
            alert("入庫数量を入力してください。");
            return false; // 阻止表单提交
        }
        if (isNaN(nyuukosuu) || parseInt(nyuukosuu) <= 0) {
            alert("入庫数量は1以上の正数を入力してください。");
            return false; // 阻止表单提交
        }
        return true; // 允许表单提交
    }

    // 页面加载时聚焦到商品代码输入框
    function on_focus(){
        document.nyuukoForm.shouhin_code.focus();
    }
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td height="55" colspan="2">
            <table width=100% height="56" border=0 cellPadding=0 cellSpacing=0>
                <tbody>
                <tr bordercolor="0">
                    <td height="49" bgColor=#666666>
                        <table cellSpacing=0 cellPadding=0 width=100 border=0>
                            <tbody>
                            <tr bordercolor="0">
                                <td><img th:src="@{/img/header_logo_rt.gif}" width=1 border=0><img
                                        height=1 alt="Skip to page content"
                                        th:src="@{/img/sp.gif}" width=1
                                        border=0></td>
                                <td><img th:src="@{/img/header_logo.gif}" width="185" height="49" border="0"></td>
                                <td><img height=49 alt=""
                                         th:src="@{/img/header_logo_rt.gif}"
                                         width=105 border=0></td>
                                <td><img
                                        height=49 alt="" th:src="@{/img/header_title.gif}"
                                        width=329 border=0></td>
                            </tr>
                            </tbody>
                        </table></td>
                    <td align=right bgColor=#666666>&nbsp;</td>
                </tr>
                <tr align="right">
                    <td colSpan=3 bgColor=#000000><img height=5 alt=""
                                                       th:src="@{/img/sp.gif}">
                        <script type="text/javascript" th:src="@{/js/time.js}"></script>
                        <span id="clock"></span></td>
                </tr>
                </tbody>
            </table>
        </td>
    </tr>
    <tr>
        <td width="152" height="100%" rowspan="2" valign="top" bgcolor="#FFFFFF">
            <TABLE width="152" height="501" border="0" cellpadding="0" cellspacing="0">
                <TR>
                    <script type="text/javascript" src="/js/menu.js" language="JavaScript"></script>

                    <DIV class=main id=main5 onclick=expandIt(5)>
                        <TD width="152" height="285" valign="top" bgcolor="#FFFFFF"
                            STYLE="border-right: 1px solid rgb(204, 204, 204);">
                            <IMG height=11 alt="" src="/img/nav_divider.gif" width=150>
                            <DIV class=main id=main1 onClick=expandIt(1)
                                 th:classappend="${session.loginDeptName} != '営業課' ? ' disabled' : ''">
                                <span class="titlefont">受注管理</span>
                                <DIV class=sub id=sub1 STYLE="display:none"
                                     th:classappend="${session.loginDeptName} != '営業課' ? ' disabled' : ''">
                                    <A th:if="${session.loginDeptName} == '営業課'" href="@{'/PR10101'}">受注入力<BR>
                                    </A>
                                    <A th:unless="${session.loginDeptName} == '営業課'" class="disabled"
                                       href="javascript:void(0)">受注入力<BR> </A>
                                    <A th:if="${session.loginDeptName} == '営業課'" th:href="@{/PR10201}">商品別出庫表作成<BR>
                                    </A>
                                    <A th:unless="${session.loginDeptName} == '営業課'" class="disabled"
                                       href="javascript:void(0)">商品別出庫表作成<BR> </A>

                                    <span class="titlefont">月報作成<IMG
                                            src="/img/arrow_pagenext2.gif"> </span>
                                    <BR>
                                    <IMG src="/img/nav_arrow.gif">
                                    <A th:if="${session.loginDeptName} == '営業課'" href="PR10301.HTML">顧客別受注実績月報作成<BR>
                                    </A>
                                    <A th:unless="${session.loginDeptName} == '営業課'" class="disabled"
                                       href="javascript:void(0)">顧客別受注実績月報作成<BR> </A>
                                    <IMG src="/img/nav_arrow.gif">
                                    <A th:if="${session.loginDeptName} == '営業課'" th:href="@{/PR10401}">商品別受注実績月報作成<BR>
                                    </A>
                                    <A th:unless="${session.loginDeptName} == '営業課'" class="disabled"
                                       href="javascript:void(0)">商品別受注実績月報作成<BR> </A>
                                    <A th:if="${session.loginDeptName} == '営業課'"
                                       th:href="@{/PR10501}">在庫情報確認</A>
                                    <A th:unless="${session.loginDeptName} == '営業課'" class="disabled"
                                       href="javascript:void(0)">在庫情報確認</A>
                                </DIV>
                                <IMG height=11 alt="" src="/img/nav_divider.gif" width=150>
                            </DIV>
                            <DIV class=main id=main2 onClick=expandIt(2)
                                 th:classappend="${session.loginDeptName} != '経理課' ? ' disabled' : ''">
                                <span class="titlefont">売掛管理</span>
                                <DIV class=sub id=sub2 STYLE="display:none"
                                     th:classappend="${session.loginDeptName} != '経理課' ? ' disabled' : ''">
                                    <A th:if="${session.loginDeptName} == '経理課'" th:href="@{/PR20101}">売掛登録<BR>
                                    </A>
                                    <A th:unless="${session.loginDeptName} == '経理課'" class="disabled"
                                       href="javascript:void(0)">売掛登録<BR> </A>
                                    <A th:if="${session.loginDeptName} == '経理課'" th:href="@{/PR20201}">代金請求<BR>
                                    </A>
                                    <A th:unless="${session.loginDeptName} == '経理課'" class="disabled"
                                       href="javascript:void(0)">代金請求<BR> </A>
                                    <A th:if="${session.loginDeptName} == '経理課'" th:href="@{/PR20301}">入金登録</A>
                                    <A th:unless="${session.loginDeptName} == '経理課'" class="disabled"
                                       href="javascript:void(0)">入金登録</A>
                                </DIV>
                                <IMG height=11 alt="" src="/img/nav_divider.gif" width=150>
                            </DIV>
                            <DIV class=main id=main3 onClick=expandIt(3)
                                 th:classappend="${session.loginDeptName} != '倉庫課' ? ' disabled' : ''">
                                <span class="titlefont">発注管理</span>
                                <DIV class=sub id=sub3 STYLE="display:none"
                                     th:classappend="${session.loginDeptName} != '倉庫課' ? ' disabled' : ''">
                                    <A th:if="${session.loginDeptName} == '倉庫課'" th:href="@{/PR30101}">発注書作成<BR>
                                    </A>
                                    <A th:unless="${session.loginDeptName} == '倉庫課'" class="disabled"
                                       href="javascript:void(0)">発注書作成<BR> </A>
                                    <A th:if="${session.loginDeptName} == '倉庫課'" th:href="@{/PR30201}">検品入庫</A>
                                    <A th:unless="${session.loginDeptName} == '倉庫課'" class="disabled"
                                       href="javascript:void(0)">検品入庫</A>
                                </DIV>
                                <IMG height=11 alt="" src="/img/nav_divider.gif" width=150>
                            </DIV>
                            <DIV class=main id=main4 onClick=expandIt(4)
                                 th:classappend="${session.loginDeptName} != '経理課' ? ' disabled' : ''">
                                <span class="titlefont">買掛管理</span>
                                <DIV class=sub id=sub4 STYLE="display:none"
                                     th:classappend="${session.loginDeptName} != '経理課' ? ' disabled' : ''">
                                    <A th:if="${session.loginDeptName} == '経理課'" href="PR40101.HTML">買掛登録<BR>
                                    </A>
                                    <A th:unless="${session.loginDeptName} == '経理課'" class="disabled"
                                       href="javascript:void(0)">買掛登録<BR> </A>
                                    <A th:if="${session.loginDeptName} == '経理課'" href="PR40201.HTML">支払伝票作成</A>
                                    <A th:unless="${session.loginDeptName} == '経理課'" class="disabled"
                                       href="javascript:void(0)">支払伝票作成</A>
                                    <BR>
                                    <A th:if="${session.loginDeptName} == '経理課'" href="PR40301.HTML">支払額登録</A>
                                    <A th:unless="${session.loginDeptName} == '経理課'" class="disabled"
                                       href="javascript:void(0)">支払額登録</A>
                                </DIV>
                                <IMG height=11 alt="" src="/img/nav_divider.gif" width=150>
                            </DIV>
                            <DIV class=main id=main5 onClick=expandIt(5) th:classappend="' disabled'"><span
                                    class="titlefont">情報管理</span>
                                <DIV class=sub id=sub5 style="display:none" th:classappend="' disabled'"><A
                                        href="PR50101.HTML">顧客情報管理<br>
                                </A><a href="PR50201.HTML">商品情報管理</A><br>
                                    <A href="PR50301.HTML">仕入先情報管理</A><br>
                                    <A href="PR50401.HTML">担当者情報管理</A><br>
                                    <A href="/HTML/PR50501.HTML">部門情報管理</A>
                                </DIV>

                </TR>
                <TR>
                    <TD height="48" valign="top" bordercolor="0">
                        <img src="/img/b.jpg" width="152" height="216" border="0" align="top">
                </TR>
            </TABLE>
        </td>
        <td height="400" align="center" valign="top">
            <table>
                <tr>
                    <td width="700">
                        <div class="header3">
                            <BR>
                        </div>
                        <div class="bfont" align="left">
                            ログイン：<span th:text="${loginUser}">張毅</span>
                        </div>
                        <BR>
                        <div class="bfont" align="left">
                            発注管理−＞検品入庫
                        </div>
                    </td>
                    <td width="200">
                        <div class="bfont" align="right">
                            <span class="titlefont"><a th:href="@{/LOGON}">首頁</a></span><span class="titlefont">｜</span>
                            <span class="titlefont"><a th:href="@{/INDEX}">退出</a></span>
                        </div>
                    </td>
                </tr>
            </table>
            <HR>
            <center>
                <!-- 错误提示区域 -->
                <div class="error-message" th:if="${error != null}" th:text="${error}"></div>
                <!-- 成功提示区域 -->
                <div class="success-message" th:if="${message != null}" th:text="${message}"></div>

                <form name="nyuukoForm" method="POST" th:action="@{/PR30201}" th:object="${nyuukoForm}">
                    <table width="385" border="0" cellpadding="5">
                        <tr align="left">
                            <th width="72" valign="middle" nowrap class="datafont">商品コード</th>
                            <td width="94" nowrap>
                                <input type="text" name="shouhin_code" th:field="*{shouhinCode}" maxlength="5" size="10">
                            </td>
                            <td width="181" colspan="2" nowrap>
                                <span class="datafont">
                                    <!-- 检索按钮：点击后调用handleSearch -->
                                    <input type="submit" name="submit" value="検索" onClick="handleSearch()">
                                </span>
                            </td>
                        </tr>
                        <tr align="left" valign="top">
                            <th colspan="4" nowrap class="datafont">
                                <table width="354" height="29" border="0" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td width="84" height="29" class="datafont">商品名</td>
                                        <td width="173">
                                            <!-- 商品名：readonly（只读但提交值） -->
                                            <input type="text" name="shouhin_mei" th:field="*{shouhinMei}" maxlength="20" size="23" readonly="readonly">
                                        </td>
                                        <td width="45" class="datafont">在庫数</td>
                                        <td width="52">
                                            <!-- 库存数：readonly（核心修改！解决值不提交问题） -->
                                            <input type="text" name="zayikosuu" th:field="*{zayikosuu}" maxlength="4" size="5" readonly="readonly">
                                        </td>
                                    </tr>
                                </table>
                            </th>
                        </tr>
                        <tr align="left">
                            <th nowrap class="datafont">入庫数量</th>
                            <td align="left" nowrap>
                                <input type="text" name="nyuukosuu" th:field="*{nyuukosuu}" maxlength="4" size="12" disabled="disabled">
                            </td>
                            <td colspan="2" align="left" nowrap>
                                <span class="datafont">
                                    <!-- 更新按钮：初始禁用，点击后调用handleUpdate -->
                                    <input type="submit" name="submit" value="更新" disabled="disabled" onClick="return handleUpdate()">
                                </span>
                            </td>
                        </tr>
                        <tr align="left">
                            <th nowrap class="datafont">入庫後在庫数</th>
                            <td nowrap>
                                <input type="text" name="nyuukoato_suu" th:field="*{nyuukoatoSuu}" maxlength="4" size="5" readonly="readonly">
                            </td>
                            <td align="left" nowrap>
                                <input type="button" name="uclear" value="クリア" th:onclick="|window.open('@{/PR30201}','_self')|">
                            </td>
                        </tr>
                    </table>
                </form>
            </center>
            <table width="380" height="32" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#333333">
                <tr>
                    <td class="style29" style="border-top: 1px solid rgb(204, 204, 204);">
                        <div align="center"><div align="center"><span class="datafont"></span></div>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td align="center" valign="bottom">
            <table width="100%" border="0" align="right" cellpadding="0" cellspacing="0">
                <tr>
                    <td align="right" bgcolor="#F8F9FB"><div align="left"><img th:src="@{/img/eds.jpg}" width="404" height="60"></div></td>
                    <td align="right" bgcolor="#F8F9FB"><img th:src="@{/img/struts-power.gif}" width="95" height="37"></td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td height="10" colspan="2">
            <table width=100% border=0 cellpadding=0 cellspacing=0 bgcolor="#666666">
                <tbody>
                <tr>
                    <td width="756" bgcolor="#000000"><span class="style13"><span class="style28">c2008 大連華信計算機新技術培訓中心. すべての知る権利を保留</span></span> </td>
                </tr>
                </tbody>
            </table>
        </td>
    </tr>
</table>
</body>
</html>